<template>
  <div class="hello">
    <h2 ref="title">你好啊，欢迎来到{{school}}</h2>
    <button @click="showH2">点我输出上方的h2元素</button>
  </div>
</template>

<script>
  export default {
    name:'Hello',
    data() {
        return {
            school:'尚硅谷'
        }
    },
    methods: {
        showH2(){
            console.log(this.$refs.title)
        }
    },
  }
</script>

<style scoped>
  .hello {
    background-color: skyblue;
    padding: 20px;
  }
</style>